/*
 * @brief: 
 * @Author: TzzzT
 * @Date: 2023-03-23 22:37:33
 * @LastEditTime: 2023-03-24 02:14:39
 * @LastEditors: TzzzT
 */
#pragma once

typedef struct rx_pbuf_s
{
  char *databuf;
  uint16_t datasize;
} rx_pbuf_t;

#define RX_FIFO_DEPTH 20
typedef struct uart_rx_fifo_s
{
  rx_pbuf_t * fifo[RX_FIFO_DEPTH];
  uint8_t get_index;
  uint8_t put_index;
  bool is_full;
} uart_rx_fifo_t;


typedef void (* uart_rx_cb_t)(rx_pbuf_t*);
typedef struct uart_s{
  uart_rx_cb_t rx_cb;
}uart_t;

void init_uart(uart_rx_cb_t uart_rx_cb);

void uart_pbuf_free(rx_pbuf_t *p);

esp_err_t uart_set_baud(uint32_t baudrate);
void uart_send_data(char *package, uint16_t len);

